package a.h;

import a.i.jb;

import java.awt.*;
import java.util.regex.Pattern;

class bc
  implements jb
{
  private static final Pattern a = Pattern.compile(",");
  private static final Pattern b = Pattern.compile("\\p{Space}+");
  private static final Pattern c = Pattern.compile("RGBA?\\p{Space}*\\[?|\\]");
  private static final String[] d = { "", "0", "00", "000", "0000", "00000", "000000" };
  private boolean e;
  private boolean g;
  static Class h;
  
  bc(boolean paramBoolean1, boolean paramBoolean2)
  {
    this.g = paramBoolean1;
    this.e = paramBoolean2;
  }
  
  public String a(Object paramObject, Class paramClass)
    throws IllegalArgumentException
  {
    int i = ec.t;
    if ((i != 0) || (paramObject != null))
    {
      if (i != 0) {
        break label72;
      }
      if (!(paramObject instanceof Color)) {}
    }
    else
    {
      if (i == 0) {}
      if ((h == null ? (bc.h = f("java.awt.Color")) : h).equals(paramClass)) {
        return a((Color)paramObject, this.g, this.e);
      }
    }
    label72:
    if (i == 0) {}
    return paramObject == null ? null : paramObject.toString();
  }
  
  public Object a(String paramString, Class paramClass)
    throws IllegalArgumentException
  {
    int i = ec.t;
    if (i == 0) {
      if (paramString == null) {
        return null;
      }
    }
    String str = paramString.trim();
    if (i == 0) {}
    return d(str) ? a(str) : b(str);
  }
  
  private static Color a(String paramString)
  {
    char[] arrayOfChar = paramString.toCharArray();
    switch (arrayOfChar.length)
    {
    case 1: 
      return null;
    case 4: 
      return new Color(a(arrayOfChar[1]), a(arrayOfChar[2]), a(arrayOfChar[3]), 255);
    case 5: 
      return new Color(a(arrayOfChar[1]), a(arrayOfChar[2]), a(arrayOfChar[3]), a(arrayOfChar[4]));
    case 7: 
      return new Color(e(paramString.substring(1, 3)), e(paramString.substring(3, 5)), e(paramString.substring(5)), 255);
    case 9: 
      return new Color(e(paramString.substring(1, 3)), e(paramString.substring(3, 5)), e(paramString.substring(5, 7)), e(paramString.substring(7)));
    }
    throw new NumberFormatException("Hexadecimal literal with illegal number of characters");
  }
  
  private static Color b(String paramString)
  {
    int j = ec.t;
    boolean bool = ec.s;
    String str = c.matcher(paramString).replaceAll("").trim();
    String[] arrayOfString = str.indexOf(',') > -1 ? a.split(str) : b.split(str);
    if ((j != 0) || ((arrayOfString.length >= 3) && ((j != 0) || (arrayOfString.length <= 4))))
    {
      int[] arrayOfInt = new int[arrayOfString.length];
      int i = 0;
      do
      {
        while (!bool)
        {
          if (i >= arrayOfString.length) {
            break;
          }
          arrayOfInt[i] = Integer.parseInt(arrayOfString[i]);
          i++;
        }
      } while (j != 0);
      return new Color(arrayOfInt[0], arrayOfInt[1], arrayOfInt[2], arrayOfInt.length == 4 ? arrayOfInt[3] : 255);
    }
    return null;
  }
  
  static String a(Color paramColor, boolean paramBoolean1, boolean paramBoolean2)
  {
    return paramBoolean2 ? a(paramColor, paramBoolean1) : b(paramColor, paramBoolean1);
  }
  
  static String a(Color paramColor, boolean paramBoolean)
  {
    int j = ec.t;
    if (paramColor == null) {
      return paramBoolean ? "RGBA[-,-,-,-]" : "RGB[-,-,-]";
    }
    if (j == 0) {
      if (!paramBoolean) {
        if (j != 0) {
          break label46;
        }
      }
    }
    label46:
    int i = paramColor.getAlpha() < 255 ? 1 : 0;
    StringBuffer localStringBuffer = new StringBuffer(29);
    localStringBuffer.append(i != 0 ? "RGBA[" : "RGB[");
    localStringBuffer.append(Integer.toString(paramColor.getRed()));
    localStringBuffer.append(',');
    localStringBuffer.append(Integer.toString(paramColor.getGreen()));
    localStringBuffer.append(',');
    localStringBuffer.append(Integer.toString(paramColor.getBlue()));
    if (j == 0)
    {
      if (i != 0)
      {
        localStringBuffer.append(',');
        localStringBuffer.append(Integer.toString(paramColor.getAlpha()));
      }
      localStringBuffer.append(']');
    }
    return localStringBuffer.toString();
  }
  
  static String b(Color paramColor, boolean paramBoolean)
  {
    if (ec.t == 0) {
      if (paramColor == null) {
        return paramBoolean ? "#----" : "#---";
      }
    }
    int i = paramColor.getRGB() & 0xFFFFFF;
    if (paramColor.getAlpha() < 255) {
      return '#' + a(i, 6) + a(paramColor.getAlpha(), 2);
    }
    return '#' + a(i, 6);
  }
  
  private static boolean d(String paramString)
  {
    return paramString.startsWith("#");
  }
  
  private static int a(char paramChar)
  {
    return e(new String(new char[] { paramChar, paramChar }));
  }
  
  private static int e(String paramString)
  {
    return Integer.parseInt(paramString, 16);
  }
  
  private static String a(int paramInt1, int paramInt2)
  {
    String str = Integer.toHexString(paramInt1);
    if (ec.t == 0) {}
    return d[(paramInt2 - str.length())] + str;
  }
  
  static Class f(String paramString)
  {
    try
    {
      return Class.forName(paramString);
    }
    catch (ClassNotFoundException localClassNotFoundException)
    {
      throw new NoClassDefFoundError(localClassNotFoundException.getMessage());
    }
  }
}



/* Location:           E:\idea\

 * Qualified Name:     a.h.bc

 * JD-Core Version:    0.7.0.1

 */